package com.branik.delivery.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.branik.delivery.dao.IPizzaDAO;
import com.branik.delivery.model.Pizza;

/**
 * 
 * Pizza Service
 * 
 * @author EBraga
 * @version 1.0.0
 *
 */
@Transactional(readOnly = true)
public class PizzaService implements IPizzaService {

	// PizzaDAO is injected...
	IPizzaDAO pizzaDAO;
	
	/**
	 * Add Pizza
	 * 
	 * @param  Pizza pizza
	 */
	@Transactional(readOnly = false)
	@Override
	public void addPizza(Pizza pizza) {
		getPizzaDAO().addPizza(pizza);
	}

	/**
	 * Delete Pizza
	 * 
	 * @param  Pizza pizza
	 */
	@Transactional(readOnly = false)
	@Override
	public void deletePizza(Pizza pizza) {
		getPizzaDAO().deletePizza(pizza);
	}
	
	/**
	 * Update Pizza
	 * 
	 * @param  Pizza pizza
	 */
	@Transactional(readOnly = false)
	@Override
	public void updatePizza(Pizza pizza) {
		getPizzaDAO().updatePizza(pizza);
	}
	
	/**
	 * Get Pizza
	 * 
	 * @param  int Pizza Id
	 */
	@Override
	public Pizza getPizzaById(int id) {
		return getPizzaDAO().getPizzaById(id);
	}

	/**
	 * Get Pizza List
	 * 
	 */
	@Override
	public List<Pizza> getPizzas() {	
		return getPizzaDAO().getPizzas();
	}

	/**
	 * Get Pizza DAO
	 * 
	 * @return IPizzaDAO - Pizza DAO
	 */
	public IPizzaDAO getPizzaDAO() {
		return pizzaDAO;
	}

	/**
	 * Set Pizza DAO
	 * 
	 * @param IPizzaDAO - Pizza DAO
	 */
	public void setPizzaDAO(IPizzaDAO pizzaDAO) {
		this.pizzaDAO = pizzaDAO;
	}

}
